﻿using System.Collections.Generic;
using System.Web.Mvc;
using ControleRepresentante.Common;
using ControleRepresentante.Logic.Models;
using Telerik.Web.Mvc.UI.Fluent;

namespace WebSite.ViewModels.DetailsViewModels.DetailsGridViewModels
{
    public abstract class EnderecoDetailsGridViewModel<TItem> : DetailsGridViewModel<TItem>
        where TItem : Endereco
    {
        protected EnderecoDetailsGridViewModel(HtmlHelper htmlHelper, IEnumerable<TItem> models)
            : base(htmlHelper, "Endereco", models)
        {
        }

        protected override void Columns(GridColumnFactory<TItem> configurator)
        {
            configurator.Bound(endereco => endereco.Tipo).Template(x => x.Tipo.GetDescription());
            configurator.Bound(endereco => endereco.Rua);
            configurator.Bound(endereco => endereco.Numero);
            configurator.Bound(endereco => endereco.Complemento);
            configurator.Bound(endereco => endereco.Bairro);
            configurator.Bound(endereco => endereco.CEP);
            configurator.Bound(endereco => endereco.Cidade);
            configurator.Bound(endereco => endereco.Estado);
            configurator.Bound(endereco => endereco.Observacao);
            configurator.Bound(endereco => endereco.Principal);
        }
    }

    public class EnderecoDetailsGridViewModel : EnderecoDetailsGridViewModel<Endereco>
    {
        public EnderecoDetailsGridViewModel(HtmlHelper htmlHelper, DetailsHolder detailsHolder)
            : base(htmlHelper, detailsHolder.Enderecos)
        {
        }
    }
}